Functions
Image Acquisition and Rendering

Includes APIs for registering buffers, getting images, and rendering images. More...

Functions

def MV_CC_RegisterImageCallBackEx (self, CallBackFun, pUser)
 Registers an image data callback. More...
 
def MV_CC_RegisterImageCallBackEx2 (self, CallBackFun, pUser, bAutoFree)
 Registers an image data callback. More...
 
def MV_CC_RegisterStreamExceptionCallBack (self, CallBackFun, pUser)
 Registers a stream exception callback. More...
 
def MV_CC_StartGrabbing (self)
 Starts grabbing images. More...
 
def MV_CC_StopGrabbing (self)
 Stops grabbing images. More...
 
def MV_CC_GetImageBuffer (self, stFrame, nMsec)
 Gets one frame of image using internal buffer. More...
 
def MV_CC_FreeImageBuffer (self, stFrame)
 Releases image buffer. More...
 
def MV_CC_GetPayloadSize (self, pnPayloadSize, pnAlignment)
 Gets the device payload size (including image data and Chunk data) and memory alignment method. More...
 
def MV_CC_GetOneFrameTimeout (self, pData, nDataSize, stFrameInfo, nMsec=1000)
 Gets one frame of image with timeout, and the SDK waits internally to return until data is available. More...
 
def MV_CC_ClearImageBuffer (self)
 Clears the image buffer. More...
 
def MV_CC_GetValidImageNum (self, nValidImageNum)
 Gets the number of valid images in the current image buffer. More...
 
def MV_CC_DisplayOneFrameEx (self, hWnd, pstDisplayInfo)
 Displays one frame of image (extended API 1). More...
 
def MV_CC_DisplayOneFrameEx2 (self, hWnd, pstImage, enRenderMode)
 Displays one frame of image (extended API 2). More...
 
def MV_CC_SetImageNodeNum (self, nNum)
 Sets the number of nodes for SDK internal image buffer. More...
 
def MV_CC_SetGrabStrategy (self, enGrabStrategy)
 Sets the image grabbing strategy. More...
 
def MV_CC_SetOutputQueueSize (self, nOutputQueueSize)
 Sets the number of output buffers, range: [1, ImageNodeNum]. More...
 
def MV_CC_GetDeviceInfo (self, stDevInfo)
 Gets the device information. More...
 
def MV_CC_GetAllMatchInfo (self, stInfo)
 Gets the information of all types. More...
 

Detailed Description

Includes APIs for registering buffers, getting images, and rendering images.

Function Documentation

◆ MV_CC_RegisterImageCallBackEx()

def MvCameraControl_class.MV_CC_RegisterImageCallBackEx (   self,
  CallBackFun,
  pUser 
)

Registers an image data callback.

Parameters
handle[IN] It refers to the device handle.
cbOutput[IN] It refers to the pointer to the callback function.
pUser[IN] It refers to the user-defined variable.
Returns
Returns MV_OK for success, and returns corresponding Error Code for failure.
Remarks
This API can be called after MV_CC_CreateHandle() to register an image data callback.
There are two image acquisition methods, and the two methods cannot be used together:
Note
  • When getting frame data, the upper application program should control the frequency of calling this API according to frame rate.
  • This API is not supported by MV_CAMERALINK_DEVICE devices.

◆ MV_CC_RegisterImageCallBackEx2()

def MvCameraControl_class.MV_CC_RegisterImageCallBackEx2 (   self,
  CallBackFun,
  pUser,
  bAutoFree 
)

Registers an image data callback.

After callback, you need to call MV_CC_FreeImageBuffer() to release image buffer.

Parameters
handle[IN] It refers to the device handle.
cbOutput[IN] It refers to the pointer to the callback function.
bAutoFree[IN] It refers to the mark for automatic releasing of image buffer.
  • true: The image buffer will be released and reused by SDK after callback.
  • false: After callback, it is required to call MV_CC_FreeImageBuffer() to release and reuse the image buffer.
pUser[IN] It refers to the user-defined variable.
Returns
Returns MV_OK for success, and returns corresponding Error Code for failure.
Remarks
This API can be called after MV_CC_CreateHandle() to register an image data callback.
Note
  • When getting frame data, the upper application program should control the frequency of calling this API according to frame rate.
  • This API is not supported by Camera Link devices.
  • The parameter pstFrame in the callback function is a temporary variable within the SDK, and its contents should be copied before being used outside the image callback function.

◆ MV_CC_RegisterStreamExceptionCallBack()

def MvCameraControl_class.MV_CC_RegisterStreamExceptionCallBack (   self,
  CallBackFun,
  pUser 
)

Registers a stream exception callback.

Parameters
handle[IN] It refers to the device handle.
cbException[IN] It refers to the pointer to the exception callback function.
pUser[IN] It refers to the user-defined variable.
Returns
Returns MV_OK for success, and returns corresponding Error Code for failure.

◆ MV_CC_StartGrabbing()

def MvCameraControl_class.MV_CC_StartGrabbing (   self)

Starts grabbing images.

Parameters
handle[IN] It refers to the device handle.
Returns
Returns MV_OK for success, and returns corresponding Error Code for failure.

◆ MV_CC_StopGrabbing()

def MvCameraControl_class.MV_CC_StopGrabbing (   self)

Stops grabbing images.

Parameters
handle[IN] It refers to the device handle.
Returns
Returns MV_OK for success, and returns corresponding Error Code for failure.

◆ MV_CC_GetImageBuffer()

def MvCameraControl_class.MV_CC_GetImageBuffer (   self,
  stFrame,
  nMsec 
)

Gets one frame of image using internal buffer.

Parameters
handle[IN] It refers to the device handle.
pstFrame[IN][OUT] It refers to the image data and information.
nMsec[IN] It refers to the timeout duration, unit: millisecond. You can input INFINITE to set unlimited timeout period, and image grabbing will not stop until a frame of data is received or the image grabbing is manually stopped.
Returns
Returns MV_OK for success, and returns corresponding Error Code for failure.
Remarks
  • Before calling this API to get image data frame, call MV_CC_StartGrabbing() to start image acquisition. This API can get frame data actively, and the upper application program should control the frequency of calling this API according to the frame rate.
  • This API supports setting timeout duration for receiving image data frames, which helps ensure stable image acquisition. It is applicable to scenes with high-stability requirement for getting images.
  • This API and MV_CC_FreeImageBuffer() should be called in pairs. After processing the acquired data, you should call MV_CC_FreeImageBuffer() to release the data pointer permission of pstFrame.
  • This API's image buffer is allocated by the SDK internally, so it has higher image acquisition efficiency than MV_CC_GetOneFrameTimeout(), whose image buffer needs to be manually allocated by the user.
  • This API cannot be called to get images after MV_CC_Display().

◆ MV_CC_FreeImageBuffer()

def MvCameraControl_class.MV_CC_FreeImageBuffer (   self,
  stFrame 
)

Releases image buffer.

Parameters
handle[IN] It refers to the device handle.
pstFrame[IN] It refers to the image data and information.
Returns
Returns MV_OK for success, and returns corresponding Error Code for failure.
Remarks

◆ MV_CC_GetPayloadSize()

def MvCameraControl_class.MV_CC_GetPayloadSize (   self,
  pnPayloadSize,
  pnAlignment 
)

Gets the device payload size (including image data and Chunk data) and memory alignment method.

It is used by the application layer to allocate sufficient buffer and correct memory alignment when registering external buffer for SDK.

Parameters
handle[IN] It refers to the device handle.
pnPayloadSize[IN][OUT] It refers to the payload size.
pnAlignment[IN][OUT] It refers to the alignment bytes.
Returns
Returns MV_OK for success, and returns corresponding Error Code for failure.
Remarks
If you need to increase the payload size, you should increase it by an integer multiple of the alignment bytes.

◆ MV_CC_GetOneFrameTimeout()

def MvCameraControl_class.MV_CC_GetOneFrameTimeout (   self,
  pData,
  nDataSize,
  stFrameInfo,
  nMsec = 1000 
)

Gets one frame of image with timeout, and the SDK waits internally to return until data is available.

Parameters
handle[IN] It refers to the device handle.
pData[IN][OUT] It refers to the pointer to image data buffer.
nDataSize[IN] It refers to the receive buffer size.
pstFrameInfo[IN][OUT] It refers to the structure of image information.
nMsec[IN] It refers to the timeout duration, unit: millisecond.
Returns
Returns MV_OK for success, and returns corresponding Error Code for failure.
Remarks
  • Before calling this API to get image data frame, call MV_CC_StartGrabbing() to start image acquisition.
  • This API can get frame data actively, and the upper application program should control the frequency of calling this API according to the frame rate.
  • This API supports setting timeout duration for receiving image data frames, which helps ensure stable image acquisition. It is applicable to scenes with high-stability requirement for getting images.

◆ MV_CC_ClearImageBuffer()

def MvCameraControl_class.MV_CC_ClearImageBuffer (   self)

Clears the image buffer.

Parameters
handle[IN] It refers to the device handle.
Returns
Returns MV_OK for success, and returns corresponding Error Code for failure.
Remarks
  • Call this API to clear the images you do not need in the buffer when the image grabbing is in progress.
  • After switching to trigger mode from continuous mode, you can call this API to clear historical data buffer.
  • This API can only be called to clear the image buffer within the SDK, and it cannot clear the buffer within the frame grabber.

◆ MV_CC_GetValidImageNum()

def MvCameraControl_class.MV_CC_GetValidImageNum (   self,
  nValidImageNum 
)

Gets the number of valid images in the current image buffer.

Parameters
handle[IN] It refers to the device handle.
pnValidImageNum[IN][OUT] It refers to the pointer to the number of valid images in the current image buffer.
Returns
Returns MV_OK for success, and returns corresponding Error Code for failure.
Remarks
This API can only be called to get the number of valid images within the SDK, not the number of those in frame grabbers.

◆ MV_CC_DisplayOneFrameEx()

def MvCameraControl_class.MV_CC_DisplayOneFrameEx (   self,
  hWnd,
  pstDisplayInfo 
)

Displays one frame of image (extended API 1).

Parameters
handle[IN] It refers to the device handle.
hWnd[IN] It refers to the window handle.
pstDisplayInfo[IN] It refers to the image information.
Returns
Returns MV_OK for success, and returns corresponding Error Code for failure.
Remarks
This API supports converting image width and image height to integer type data.

◆ MV_CC_DisplayOneFrameEx2()

def MvCameraControl_class.MV_CC_DisplayOneFrameEx2 (   self,
  hWnd,
  pstImage,
  enRenderMode 
)

Displays one frame of image (extended API 2).

Parameters
handle[IN] It refers to the device handle.
hWnd[IN] It refers to the window handle.
pstImage[IN] It refers to the image information.
enRenderMode[IN] It refers to the image rendering mode. In Linux operating system, 0: OpenGL.
Returns
Returns MV_OK for success, and returns corresponding Error Code for failure.
Remarks
  • This API supports rendering of images over 4 GB in PixelType_Gvsp_RGB8_Packed, PixelType_Gvsp_BGR8_Packed, and PixelType_Gvsp_Mono8 formats.
  • For images under 4 GB, the image width and image height can be converted to integer type data.
  • When calling the API, it is required to enter the nImageLen value of structure MV_CC_IMAGE .

◆ MV_CC_SetImageNodeNum()

def MvCameraControl_class.MV_CC_SetImageNodeNum (   self,
  nNum 
)

Sets the number of nodes for SDK internal image buffer.

The value is no less than 1, and this API should be called before calling MV_CC_StartGrabbing().

Parameters
handle[IN] It refers to the device handle.
nNum[IN] It refers to the number of buffer nodes.
Returns
Returns MV_OK for success, and returns corresponding Error Code for failure.
Remarks
  • Call this API before MV_CC_StartGrabbing() to set the number of nodes for SDK internal image buffer.
  • Image grabbing methods vary from different camera types. If this API is not called, the default number of buffer nodes will be different.
    • Memory verification will be performed for GigE Vision devices and USB3 devices when MV_CC_StartGrabbing() is called, and an error will be returned if the system memory is insufficient.
    • For cameras connected to frame grabbers, if the memory allocated by the system is insufficient when MV_CC_StartGrabbing() is called, the pre-allocated nodes for SDK will be calculated again, and the actual number of allocated nodes will be set to the number of latest pre-allocated nodes.

◆ MV_CC_SetGrabStrategy()

def MvCameraControl_class.MV_CC_SetGrabStrategy (   self,
  enGrabStrategy 
)

Sets the image grabbing strategy.

Parameters
handle[IN] It refers to the device handle.
enGrabStrategy[IN] It refers to the strategy enumeration value.
Returns
Returns MV_OK for success, and returns corresponding Error Code for failure.
Remarks
There are four defined image grabbing strategies, from which you can choose the suitable one according to the actual requirement.
  • OneByOne: Gets image frames one by one in chronological order. It is the default strategy.
  • LatestImagesOnly: Only gets the latest one frame from the output buffer list, and clears the rest images in the list.
  • LatestImages: Gets the latest image of OutputQueueSize frame from the output buffer list. The range of OutputQueueSize is between 1 and ImageNodeNum. If the OutputQueueSize value is set to 1, the strategy is same to LatestImagesOnly, and if the OutputQueueSize value is set to ImageNodeNum, the strategy is same to OneByOne. You can set the OutputQueueSize via API MV_CC_SetOutputQueueSize(), and set the ImageNodeNum via API MV_CC_SetImageNodeNum().
  • UpcomingImage: Ignores all images in the output buffer list during calling image grabbing API (MV_CC_GetOneFrameTimeout() or MV_CC_GetImageBuffer() ), and waits for the upcoming image generated by the device.
  • Supports devices such as MV_USB_DEVICE , MV_GENTL_GIGE_DEVICE , MV_GENTL_CAMERALINK_DEVICE , MV_GENTL_CXP_DEVICE , and MV_GENTL_XOF_DEVICE .

◆ MV_CC_SetOutputQueueSize()

def MvCameraControl_class.MV_CC_SetOutputQueueSize (   self,
  nOutputQueueSize 
)

Sets the number of output buffers, range: [1, ImageNodeNum].

Parameters
handle[IN] It refers to the device handle.
nOutputQueueSize[IN] It refers to the number of output buffers.
Returns
Returns MV_OK for success, and returns corresponding Error Code for failure.
Remarks
  • This API is valid only when MV_CC_SetGrabStrategy() is set to LatestImages. It is called to set the maximum number of buffer images under the LatestImages strategy. You can adjust the number of output buffers during image grabbing. Supports devices such as MV_USB_DEVICE , MV_GENTL_GIGE_DEVICE , MV_GENTL_CAMERALINK_DEVICE , MV_GENTL_CXP_DEVICE , and MV_GENTL_XOF_DEVICE .

◆ MV_CC_GetDeviceInfo()

def MvCameraControl_class.MV_CC_GetDeviceInfo (   self,
  stDevInfo 
)

Gets the device information.

Parameters
handle[IN] It refers to the device handle.
pstDevInfo[IN][OUT] It refers to the pointer to device information structure.
Returns
Returns MV_OK for success, and returns corresponding Error Code for failure.
Remarks
  • Call this API after MV_CC_OpenDevice() to get the device information.
  • The API is not supported by devices added via GenTL.
  • For a GigE vision device, there is a blocking risk when calling the API, so it is not recommended to call the API during image grabbing.

◆ MV_CC_GetAllMatchInfo()

def MvCameraControl_class.MV_CC_GetAllMatchInfo (   self,
  stInfo 
)

Gets the information of all types.

Parameters
handle[IN] It refers to the device handle.
pstInfo[IN][OUT] It refers to the pointer to information structure.
Returns
Returns MV_OK for success, and returns corresponding Error Code for failure.
Remarks
Input required information type (specify nType in structure MV_ALL_MATCH_INFO ), and get corresponding information (returned via pInfo in structure MV_ALL_MATCH_INFO ).
The precondition for calling the API depends on the obtained information type.
  • To get the MV_MATCH_TYPE_NET_DETECT information (network traffic and packet loss) of GigE vision devices, call the API after MV_CC_StartGrabbing().
  • To get the MV_MATCH_TYPE_USB_DETECT information (total number of bytes received by host from USB3 vision device) of USB3 vision devices, call the API after MV_CC_OpenDevice().